<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>组件</h1>
    <div id="app">
        <my-global-component></my-global-component>
        <my-local-component></my-local-component>
    </div>
</body>
<script src="../js/vue.js"></script>
<script>
<!--    全局组件-->
    Vue.component('myGlobalComponent', {
        // template: '<div>hello global!</div>'
        template: '<div>hello global! <div id="numShow">{{num}}</div><button @click="add">次数+1</button></div>',
        data(){
            return {
                num: 0
            }
        },
        methods: {
            add(){
                this.num++
            }
        }
    })
    var vm = new Vue({
        el: '#app',
        data(){
            return {}
        },
        components: {
            'my-local-component': {
                template: '<div>hello local!</div>'
            }
        }
    })
</script>
</html>